UnitTests = class ("UnitTests")

require("TestSentences")
require("TestBook")
require("TestField")
require("TestDecoherence")
require("TestDramaManagerPruning")
require("TestGetAccessibleLocations")
require("TestGetAccessibleLocations2")
require("TestDoorCollapseSimpleDeadlockFiltering")
require("TestKeyLocationsReductionAfterDoorCollapse")
require("TestDoorCollapseComplexDeadlockFiltering")
require("TestDoorCollapseComplexDeadlockFiltering2")
require("testTellAction")
require("testBehavior")

---

function UnitTests:initialize()

	Random:new()
	
	self:testBiasedRandom()
	self:testSentences()
	self:testBook()
	self:testField()
	self:testDecoherence()
	self:testDramaManagerPruning()
	self:TestGetAccessibleLocations()
	self:TestGetAccessibleLocations2()
	self:TestDoorCollapseSimpleDeadlockFiltering()
	self:TestKeyLocationsReductionAfterDoorCollapse()
	self:TestDoorCollapseComplexDeadlockFiltering()
	self:TestDoorCollapseComplexDeadlockFiltering2()
	self:testTellAction()
	self:testBehavior()

	dofile(gRootPath .. "DeclareGlobals.lua")	-- reclear all globals
	
	print("All unit tests passed")
end

---

function UnitTests:testBiasedRandom()

	gRandom:addContextualBias({"un", "deux", "trois"}, 123)
	gRandom:addContextualBias({4, 5, 6}, "456")
	gRandom:addContextualBias({7, "huit", 9}, 789)
	
	assert(gRandom:get({"un", "deux", "trois"}) == 123)
	assert(gRandom:get({7, "huit", 9}) == 789)
	assert(gRandom:get({4, 5, 6}) == "456")
end